#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
int main() {
    int n,tmp = 1;
    cin >> n;
    vector<vector<int>> v;
    v.push_back({1});
    for (int i = 2; i <= n; ++i) {
        if (i % 2 == 0) {
            vector<int> nextLine(i);
            for (int j = 0; j < i - 1; ++j) v[j].push_back(++tmp);
            for (int j = i - 1; j >= 0; --j) nextLine[j] = ++tmp;
            v.push_back(nextLine);
        } else {
            vector<int> nextLine(i);
            for (int j = i - 2; j >= 0; --j) v[j].insert(v[j].begin(),++tmp);
            for (int j = 0; j < i; ++j) nextLine[j] = ++tmp;
            v.insert(v.begin(), nextLine);
        }
    }
    for (const auto &item: v) {
        for (const auto &item2: item) cout << item2 << " ";
        cout << endl;
    }
    return 0;
}